home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Tele
/
W-Z
/
Wait.cpt
/
Wait.source
< prev
next >
Wrap
Text File
|
1989-12-11
|
5KB
|
203 lines
DEFLNG a-z
'constants
tabch$ = CHR$(9) 'tab char
SH=SYSTEM(6) 'screen height
SW=SYSTEM(5) 'screen width
h%=150 'window height
w%=400 'window width
DIM SHARED IOPB%(60) 'for GetPathName
'setup menus
MENU 1,0,1,"File"
MENU 1,1,1,"Info" :cmdkey 1,1,"I"
MENU 1,2,0,"-"
MENU 1,3,1,"Quit" :cmdkey 1,3,"Q"
ON ERROR GOTO quit 'for any fatal error just abort to desktop
PgmRef%= SYSTEM(7) 'SYSTEM(7) returns file reference number
CALL GetPathName (PgmRef%, PgmName$)
CALL Parse (PgmName$, path$) 'separate filename and path
'get current date and time
GOSUB getDate 'reformats date to MM/DD/YY
GOSUB getTime 'gets long and "short" time formats
'update Tabby Log file
tabbylog$ = path$+"Tabby:Tabby Log"
OPEN tabbylog$ FOR APPEND AS #1
PRINT #1,today$;" ";short$;" Wait - Program Starting"
CLOSE
'Get name of next program to launch, update launch.next
launch$ = path$+"launch.next"
OPEN launch$ FOR INPUT AS #1
LINE INPUT #1, text$
CLOSE
KILL launch$ 'delete the file
i = INSTR(text$,",") 'find comma
IF i = 0 THEN 'this is last name in file
program$ = text$
ELSE
program$ = LEFT$(text$,i-1)
text$ = MID$(text$,i+1) 'remaining filenames
OPEN launch$ FOR OUTPUT AS #1 'save for next guy
PRINT #1,text$
CLOSE
END IF
'reformat time to HHMM for comparison with Tabby Events file
temp$ = LEFT$(current$,2) + MID$(current$,4,2)
'Read Events file and find out how long to wait
events$ = path$+"Tabby:Events"
OPEN events$ FOR INPUT AS #1
target$ = ""
WHILE NOT EOF (1) AND target$ = ""
LINE INPUT #1, text$
i = INSTR(text$,tabch$) 'find first tab
start$ = MID$(text$,i+1,4)
i = INSTR(i+1,text$,tabch$) 'find next tab
finish$ = MID$(text$,i+1,4)
IF start$ <= temp$ AND temp$ < finish$ THEN
'reformat target time to HH:MM:00
target$ = LEFT$(finish$,2)+":"+RIGHT$(finish$,2)+":00"
END IF
WEND
CLOSE
'check target event and wait ONLY if we found one...
IF target$ <> "" THEN 'we found one
'setup to handle Cmd-I (Info) and Cmd-Q (Quit)
ON MENU GOSUB handlemenu
MENU ON
temp$ = TIME$
WHILE temp$ < target$ 'loop until end of timed event
temp$ = TIME$
WEND
END IF
'get current date and time
GOSUB getDate
GOSUB getTime
'update Callerlog
callerlog$ = path$+"Callerlog"
OPEN callerlog$ FOR APPEND AS #1
PRINT #1,"Launching <";path$;program$;"> on ";today$;" at ";current$
CLOSE
'update Tabby Log
tabbylog$ = path$+"Tabby:Tabby Log"
OPEN tabbylog$ FOR APPEND AS #1
PRINT #1,today$;" ";short$;" Wait - Program Ending"
CLOSE
Transfer program$ 'do launch.next and...
quit:
'we're all done (or an error occured) so lets get out of here!
CLOSE 'any open files
END 'and then quit back to the desktop
'----------------------- Subroutines -------------------------
getDate:
today$ = DATE$ 'format is MM-DD-YYYY
'change format to MM/DD/YY
today$ = LEFT$(today$,2)+"/"+MID$(today$,4,2)+"/"+RIGHT$(today$,2)
RETURN
'-----------------------
getTime:
'gets current time in long and short (H:MM:SS) formats
current$ = TIME$ 'format is HH:MM:SS
short$ = current$ 'temporary time string
IF LEFT$(short$,1) = "0" THEN 'if hour is less than 10 then
short$ = MID$(short$,2) 'reformat to (H:MM:SS)
END IF
RETURN
'-----------------------
handlemenu:
MenuID= MENU(0)
MenuItem= MENU(1)
IF MenuID = 1 THEN
IF MenuItem = 1 THEN
GOSUB showinfo
ELSEIF MenuItem = 3 THEN
GOTO quit
END IF 'ignore all other cases
END IF
MENU
RETURN
'-----------------------
showinfo:
WINDOW 10,,((SW-w%)/2,(SH-h%)/3)-((SW-w%)/2+w%,(SH-h%)/3+h%),2
text$="Wait 1.0"
TEXTFONT 0
MOVETO (WINDOW(2)-WIDTH(text$))\2,20 'center title$
DrawText text$:PRINT
TEXTFONT 3
text$ = "A Tabby 2.1 Utility. Freeware by Mark J. Smith, 1989"
MOVETO (WINDOW(2)-WIDTH(text$))\2,45 'center text$
DrawText text$:PRINT
text$ = "Waiting until: " + target$
MOVETO (WINDOW(2)-WIDTH(text$))\2,75 'center text$
DrawText text$:PRINT
text$ = "Next program to launch: " + program$
MOVETO (WINDOW(2)-WIDTH(text$))\2,100 'center text$
DrawText text$:PRINT
text$ = "Click in window to close"
MOVETO (WINDOW(2)-WIDTH(text$))\2,125 'center text$
DrawText text$:PRINT
m%=MOUSE(0)
WHILE m%=0 OR m%=-1:m%=MOUSE(0):WEND
WINDOW CLOSE 10
RETURN
'----------------------- Sub-Programs -------------------------
' Gets the full path name of a file given the file reference
' number.
'
SUB GetPathName (ref%,path$) STATIC
filename$="" : Folder$=""
GetFCBInfo IOPB%(0),filename$,ref%
path$=filename$
DirID&=IOPB%(29)*65536&+IOPB%(30)
VRefNum%=IOPB%(26)
WHILE DirID&<>1
GetCatInfo IOPB%(0),Folder$,DirID&,VRefNum%
path$=Folder$+":"+path$
DirID&=IOPB%(50)*65536&+IOPB%(51)
WEND
END SUB
'----------------------------------------------------------------
SUB Parse (filename$,path$) STATIC
index%=1
WHILE index% '<>0
last%=index%
index%=INSTR(index%+1,filename$,":")
WEND
IF last%=1 THEN 'there was no path
path$=""
ELSE 'divide filename$ into path$ and filename$
path$=LEFT$(filename$,last%)
filename$=RIGHT$(filename$,LEN(filename$)-last%)
END IF
END SUB